package com.cristina.attention.utils.enums;

import com.cristina.attention.utils.AttentionCommon;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

import java.util.Objects;

/**
 * 发送渠道类型枚举 (IM)
 *
 * @author by superman
 */
@Getter
@ToString
@AllArgsConstructor
public enum ChannelType {

    /**
     *
     */
    IM_GROUP(20, "IM(群聊)", "im_group"),
    IM_CHAT(10, "IM(私聊)", "im_chat"),
    IM_PUSH(30, "IM(通知栏)", "im_push"),
    EMAIL(40, "email(邮件)", "email")
    ;

    /**
     * 编码值
     */
    private Integer code;

    /**
     * 描述
     */
    private String description;

    /**
     * 英文标识
     */
    private String codeEn;

    /**
     * 通过code获取枚举
     * @param code
     * @return
     */
    public static ChannelType getEnumByCode(Integer code) {
        ChannelType[] values = values();
        for (ChannelType value : values) {
            if (Objects.equals(value.getCode(), code)) {
                return value;
            }
        }
        return null;
    }

}
